﻿/** 名将,主要是摆拳,还有快速的上上或下下a与跳a

  By setycyas @2024-09-06
*/

/* 全局设定
*/ {
#Warn
#MaxThreadsPerHotkey 1
SetWorkingDir(A_ScriptDir)
#Include "..\Class\FaceDetector.2.ahk"
#Include "..\Class\CommonMacro.2.ahk"
#Include "..\Class\CommonUI.2.ahk"
#Include "..\Class\MyFuns.2.ahk"
#Include "..\Class\MyEmu.2.ahk"
#Include "..\Class\OrderMap.2.ahk"
SendMode("Event")
;SendMode("Input")
}

/* 制作名将的宏类
*/ class CaptcommMacro extends CommonMacro {

  pressDuration := 30

  /* 新增的宏函数
  */
  _转身摆拳(key){
    local face, back
    face := this._face.face()
    back := this._face.back()
    ;MyFuns.press(back, this.testParams[1])
    ;MyFuns.press(face, this.testParams[2])
    ;sleep(this.testParams[3])
    MyFuns.press(back, 20)
    MyFuns.press(face, 20)
    ;sleep(20)
    this._连发A(key)
  }
  
  _前后摆拳(key){
    local back
    back := this._face.back()
    MyFuns.press(back, 20)
    this._face.setFace(back)
    this._连发A(key)
  }
  
  _后跳(key){
    local back := this._face.back()
    MyFuns.keyDown(back)
    ;if (this.testParams[1] > 0){
    ;  sleep(this.testParams[1])
    ;}
    this._press(2)
    MyFuns.keyUp(back)
  }
  
  _下下a(key){
    MyFuns.press("down", 30)
    sleep(30)
    MyFuns.keyDown("down")
    sleep(30)
    this._press(1)
    MyFuns.keyUp("down")
  }
  
  _上上a(key){
    MyFuns.press("up", 30)
    sleep(30)
    MyFuns.keyDown("up")
    sleep(30)
    this._press(1)
    MyFuns.keyUp("up")
  }
  
  _下下ba(key){
    MyFuns.press("down", 30)
    sleep(30)
    MyFuns.keyDown("down")
    sleep(30)
    this._press(2)
    MyFuns.keyUp("down")
    sleep(50)
    this._press(1)
  }
  
  _上上ba(key){
    MyFuns.press("up", 30)
    sleep(30)
    MyFuns.keyDown("up")
    sleep(30)
    this._press(2)
    MyFuns.keyUp("up")
    sleep(50)
    this._press(1)
  }

  /* 重载宏接口
  */
  _setMacro(){
    this.macroMap := OrderMap()
    this.macroMap["连发A"] := this._连发A.bind(this)
    this.macroMap["转身摆拳"] := this._转身摆拳.bind(this)
    this.macroMap["前后摆拳"] := this._前后摆拳.bind(this)
    this.macroMap["后跳"] := this._后跳.bind(this)
    this.macroMap["下下a"] := this._下下a.bind(this)
    this.macroMap["上上a"] := this._上上a.bind(this)
    this.macroMap["下下ba"] := this._下下ba.bind(this)
    this.macroMap["上上ba"] := this._上上ba.bind(this)
    this.macroArr := this.macroMap.getKeys()
  }
}

/* 运行当前脚本
*/ if (A_ScriptName == "名将.2.ahk") {
  face := FaceDetector() ;方向检测对象
  macro := CaptcommMacro(face, ["q","f"]) ;宏对象,有界面时第二个参数可以随便写但长度不要小于2
  ;宏方案预设,用于菜单
  preset := OrderMap([
    "默认", 
      ["连发A", "转身摆拳", "上上a", "下下a", "前后摆拳", "后跳"],
    "队长",
      ["连发A", "转身摆拳", "上上ba", "下下ba", "前后摆拳", "后跳"]
  ])
  ;新建界面对象并显示
  ui := CommonUI("名将", macro, preset)
  ui.setup()
  ;更新组件内容
  ui._exeComboBox.Choose(MyEmu.WINKAWAKS)
  ui._gameKeyEdit.Text := "q,d"
  ui._hotkeyEdit.Text := "~s,~a,~e,~f,~x,~w"
  ui._fpsEdit.Text := 8
  ui._testEdit.Text := "30,30,30"
  ui.readPresetMenu("默认")
}
